import request from '@/utils/request'

// 获取发票申请分页列表
export function pageInvoiceManagement(query) {
  return request({
    url: '/invoice/invoiceManagement/paging',
    method: 'get',
    params: query
  })
}
// 统计发票状态数量和总金额
export function statisticalInvoiceStatusNumOrTotalAmount(query) {
  return request({
    url: '/invoice/invoiceManagement/statisticalInvoiceStatusNumOrTotalAmount',
    method: 'get',
    params: query
  })
}

// 获取发票申请列表
export function getInvoiceList(query) {
  return request({
    url: '/invoice/invoiceManagement/getInvoiceList',
    method: 'get',
    params: query
  })
}

// 保存发票详情和收件人信息
export function saveBaseAndReceiptInfo(data) {
  return request({
    url: '/invoice/invoiceManagement/saveBaseAndReceiptInfo',
    method: 'post',
    data: data
  })
}

// 保存发票
export function save(data) {
  return request({
    url: '/invoice/invoiceManagement/save',
    method: 'post',
    data: data
  })
}

// 删除发票
export function deleteInvoice(invoiceManagementId) {
  if (!invoiceManagementId) {
    return
  }
  return request({
    url: '/invoice/invoiceManagement/delete',
    method: 'post',
    params: {
      invoiceManagementId
    }
  })
}
// 修改发票状态
export function doBatchUpdateStatus(data) {
  return request({
    url: '/invoice/invoiceManagement/doBatchUpdateStatus',
    method: 'post',
    data: data
  })
}
// 获取能开票的总金额
// 待提交的，不算在内，因为页面有可能在编辑，有新增的金额，如果计算的话，容易多扣。
export function getCanInvoiceTotalAmount(data) {
  return request({
    url: '/invoice/invoiceManagement/getCanInvoiceTotalAmount',
    method: 'post',
    data: data
  })
}
